#ifndef _Q_SYMBOLS_H
#define _Q_SYMBOLS_H

#include "qe_vars.h"
#include "qe_func.h"
#include "qe_structdef.h"

#define MAX_SYM_LEN 256
#define SYMBOLS_TABLE_SIZE 256 /* must be power of 2 */

/* symbol types */
enum q_symboltype {SYMBOL_VARIABLE = 0, SYMBOL_FUNCTION, SYMBOL_STRUCTDEF, SYMBOL_BUILDIN};

enum q_scopetype {SCOPE_NORMAL = 0, SCOPE_FUNCTION, SCOPE_GLOBAL};

/* universal symbol container */
struct q_symbolcontainer
{
	char name[MAX_SYM_LEN];
	enum q_symboltype type;
	struct q_symbolcontainer* next;
	union
	{
		struct q_variable* var;
		struct q_func* func;
#if 0 /* remove after filling q_symbols.h */
		struct q_structdef structdef;
#endif
	};
};

struct q_symbolscope
{
	enum q_scopetype type;
	struct q_symbolcontainer* table[SYMBOLS_TABLE_SIZE];
	struct q_symbolscope* prev;
};

struct  q_symbolscopepool
{
	struct q_symbolscope* global;
	struct q_symbolscope* current;
};

struct q_dissallowed
{
	char name[MAX_SYM_LEN];
	struct q_dissallowed* next;
};

int q_initsymboltable();
struct q_variable* q_getvariable(const char* const variable);
/* current symbols */
extern struct q_symbolscopepool q_symbols;



#endif
